﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TerraExplorerX;
using ComponentFactory.Krypton.Toolkit;


namespace UI
{
    public partial class PointSelectForm : KryptonForm
    {
        private ISGWorld61 sgworld;        
        private string selectedLayerName = string.Empty;
        public PointSelectForm(ISGWorld61 sgw)
        {
            InitializeComponent();
            this.sgworld = sgw;
        }

        private void PointSelectForm_Load(object sender, EventArgs e)
        {
            sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem(ConfigurationManager.AppSettings["CRLayer"]), true);            
            this.CboxLayer.Items.Add(ConfigurationManager.AppSettings["CRLayer"]);
            this.CboxLayer.Items.Add("医院");
            this.CboxLayer.Items.Add("消防");
            this.CboxLayer.Items.Add("校园道路");
            this.CboxLayer.SelectedIndex = 0;
           
        }

        

        private void button1_Click(object sender, EventArgs e)
        {          
            PointQueryCommand pq = new PointQueryCommand();
            int itemID = sgworld.ProjectTree.FindItem(this.selectedLayerName);
            ILayer61 routeLayer = sgworld.ProjectTree.GetLayer(itemID);
            int bufferRadius = Int32.Parse(ConfigurationManager.AppSettings["BufferRadius"]);
            pq.Execute(routeLayer, bufferRadius,listView1);
        }

        private void CboxLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.selectedLayerName = this.CboxLayer.SelectedItem.ToString();
        }

        
    }
}
